package com.gree.scmservice.dao.saasDao;

/**
 * Created by 180686 on 2021/10/19 14:58
 */

import com.gree.scmservice.entity.saas.SaasMenuAddon;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.nutz.dao.Dao;
import org.nutz.dao.Cnd;
import org.nutz.dao.pager.Pager;
import java.util.List;
import com.gree.common.entity.TablePageData;


/**
 * 菜单插件对象 SAAS_MENU_ADDON
 *
 * @author gscm
 * @date 2021-10-19
 */
@Repository
public class SaasMenuAddonDao
{
    @Autowired
    private Dao dao;

    public SaasMenuAddon insertSaasMenuAddon(SaasMenuAddon saasMenuAddon){
        SaasMenuAddon insert = dao.insert(saasMenuAddon);
        return insert;
    }

    public int deleteSaasMenuAddonById(Long addonId){
        int delete = dao.clear(SaasMenuAddon.class, Cnd.where("addon_id", "=", addonId));
        return delete;
    }

    public int deleteSaasMenuAddonByIds(Long[] addonIds){
        int delete = dao.clear(SaasMenuAddon.class, Cnd.where("addon_id", "in", addonIds));
        return delete;
    }

    public int updateSaasMenuAddon(SaasMenuAddon saasMenuAddon){
        int update = dao.update(saasMenuAddon);
        return update;
    }

    public List<SaasMenuAddon> selectSaasMenuAddonById(Long addonId){
        List<SaasMenuAddon> saasMenuAddonList = dao.query(SaasMenuAddon.class, Cnd.where("addon_id", "=", addonId));
        return saasMenuAddonList;
    }

    public TablePageData selectSaasMenuAddonList(SaasMenuAddon saasMenuAddon){
        Pager pager = dao.createPager(saasMenuAddon.getPageNum(), saasMenuAddon.getPageSize());
        saasMenuAddon.saasMenuAddonNoPage();
        Cnd cnd = Cnd.from(dao,saasMenuAddon);
        List query = dao.query(SaasMenuAddon.class, cnd, pager);
        TablePageData tablePageData = new TablePageData(query, pager);
        return tablePageData;
    }

}